using System;
using XSResearch;
using XSResearch.Monitoring;
using XSResearch.Utilities;

class BasicAgentExample
{
    public static void RunExample()
    {
        // 初始化组件
        var logger = new AppLogger();
        var monitor = new PerformanceMonitor(logger);
        var errorHandler = new ErrorHandler(logger);
        
        // 创建XR接口和数据处理器
        var xrInterface = new XRInterface();
        var dataAnalyzer = new DataAnalyzer();
        
        // 创建研究智能体
        var agent = new ResearchAgent("ExampleAgent", xrInterface, dataAnalyzer)
        {
            ExplorationRate = 0.3,
            LearningRate = 0.1
        };

        // 基础研究循环
        for (int i = 0; i < 100; i++)
        {
            monitor.StartOperation($"Cycle_{i}");
            
            try {
                agent.Perceive();
                agent.Decide();
                agent.Act();
                agent.Learn();
                
                // 每10轮记录一次
                if (i % 10 == 0) {
                    logger.Log($"Completed cycle {i}", LogLevel.Info);
                }
            }
            catch (Exception) {
                errorHandler.ExecuteWithRetry(() => {
                    // 错误恢复逻辑
                    xrInterface.ConnectXRDevice();
                    return true;
                }, OperationType.DataProcessing);
            }
            
            monitor.EndOperation($"Cycle_{i}");
        }
        
                        // Performance metrics are automatically logged
    }
}